/**
 * Created by zhangwx on 2015/12/4.
 */

$(function() {
    $("input[name='type']").click(function () {

        changeType();
    });

});

/**
 * 用户分析
 */
function getUserRouteInfo() {

    $.ajax({
        type : "POST",
        url : "../../mapAnalysis/UserRoute",
        data : {
            beginDate :beginDate,
            endDate : endDate,
            userType :userType,
            userValue :userValue
        },
        dataType : "json",
        success : function(data) {
            window.frames['map'].initData(data,{
                type: "user",
                data: "data",
                lonb: "lonb",
                latb: "latb",
                displayField: [{label:"上行流量",value:"flow_up"},{label:"下行流量",value:"flow_down"}],
                userInfo: "userInfo",
                cityCode: "city_code"
            });
        }
    });
}
/**
 * 用户组分析
 */
function getUserRouteInfo() {

    var dimension = $('input:radio[name="ab"]:checked').val();
    var dimensionVal = getDimensionValue(dimension)
    var startTime = $("#startTime").val();
    var endTime = $("#endTime").val();
    var _3g = $('#_3g').is(':checked');
    var _4g = $('#_4g').is(':checked');

    $.ajax({
        type : "POST",
        url : "../../mapAnalysis/UserGroupRoute",
        data : {
            beginDate :startTime,
            endDate : endTime,
            _3g:_3g,
            _4g:_4g,
            dimensionVal:dimensionVal,
            dimension:dimension
        },
        dataType : "json",
        success : function(data) {
            window.frames['map'].initData(data,{
                type:"group",
                data:"data",
                lonb:"lonb",
                latb:"latb",
                displayField: [{label:"上行流量",value:"flow_up"},{label:"下行流量",value:"flow_down"}]

            });
        }
    });
}



/**
 * 区域分析
 */
function getAreaHeatMap(){


    $.ajax({

        type : "POST",
        url : "../../mapAnalysis/UserGruopAreaHeatMap",
        data : {
            timeType:param.timeSize,
            nowDate: param.queryDate,
            area_code:param.city_code
        },
        dataType : "json",
        success : function(data) {
            MapData=data;
            changeType();

        }
    });


}

function changeType(){
    if(!MapData) return;
    var ops={
        type:"groupMap",
        data:"data",
        lonb:"lonb",
        latb:"latb",
        displayField:[],
        max:100,//值
        count:"count"
    };

    switch($("input[name='type'][checked]").val()){
        case "userNum":
            ops.data="UserNumAndFlow";
            if(MapData["UserNumAndFlowMax"]){
                ops.max=MapData["UserNumAndFlowMax"].count;
                ops.count="count";
            }else{
                ops.max=100;
                ops.count="count";
            }


            break;
        case "flow":
            ops.data="UserNumAndFlow";
            ops.max=MapData["UserNumAndFlowMax"].flow_totalmax;
            ops.count="flow_total";
            break;
        case "firstTime":
            ops.data="FirstPacket";
            ops.max=MapData["FirstPacketMax"].firstpacket_timemax;
            ops.count="firstpacket_time";
            break;
        default :
            ops.data="UserNumAndFlow";
            ops.max=MapData["UserNumAndFlowMax"].count;
            ops.count="count";
            break;
    }
    window.frames['map'].initData(MapData,ops);
}



/**
 * KQI分析
 */
function getKQIHeatMap(){
    $.ajax({
        type : "POST",
        url : "../../mapAnalysis/KpiHeatMap",
        data : {
            timeSize:$('input:radio[name="timeSize"]:checked').val(),
            type: $('input:radio[name="tt"]:checked').val(),
            city:$("#sgw").val(),
            beginDate:$("#beginDate").val(),
            endDate:$("#endDate").val()
        },
        dataType : "json",
        success : function(data) {
            window.frames['map'].initData(data,{
                type:"groupMap",
                data:"data",
                lonb:"lonb",
                latb:"latb",
                displayField:[],
                max:data["maxValue"].maxvalue,//值
                count:"value"
            });
        }
    });


}